package com.wechat.back.mapper;

import com.wechat.back.pojo.Place;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PlaceMapper {
    //通过id查询
    @Select("select * from place where poi_id=#{poiId}")
    Place findById(Integer poiId);

    //增加
    @Insert("insert into place(district_name, poi_name,distance_str,tag_list1,tag_list2,price,latitude,longitude,comment_score,comment_count,cover_imageUrl,introduction,poi_type)"+
    "values (#{districtName},#{poiName},#{distanceStr},#{tagList1},#{tagList2},#{price},#{latitude},#{longitude},#{commentScore},#{commentCount},#{coverImageUrl},#{introduction},#{poiType})")
    void add(Place place);

    @Delete("delete from place where poi_id=#{poiId}")
    void deleteById(Integer poiId);

    @Update("update place set district_name=#{districtName},poi_name=#{poiName},distance_str=#{distanceStr},tag_list1=#{tagList1},tag_list2=#{tagList2},price=#{price},comment_score=#{commentScore},comment_count=#{commentCount},latitude=#{latitude},longitude=#{longitude},cover_imageUrl=#{coverImageUrl},introduction=#{introduction},poi_type=#{poiType} where poi_id=#{poiId}" )
    void update(Place place);

    //列表
    List<Place> list(String poiName, String poiType);

    //评分和评论加权推荐
    List<Place> listByCommentRecommend(String poiType);

    @Select("select * from place where poi_type=#{poiType}")
    List<Place> listAllByType(String poiType);

}
